package com.jiuair.cloud.data.revenue.demo;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Description:
 * @Author: dengh
 * @Date: 2023/2/10 15:15
 * @Version: 1.0
 */
public class Test {
    public static void main(String[] args) {
        //定义水果
        Fruits apple = new Fruits();
        apple.setName("苹果");
        apple.setPrice(new BigDecimal("8"));
        Fruits strawberry = new Fruits();
        strawberry.setName("草莓");
        strawberry.setPrice(new BigDecimal("13"));
        Fruits mango = new Fruits();
        mango.setName("芒果");
        mango.setPrice(new BigDecimal("20"));

        BigDecimal applePrice = apple.getPrice();
        BigDecimal strawberryPrice = strawberry.getPrice();
        BigDecimal mangoPrice = mango.getPrice();

        Integer a =1;
        Integer b=2;
        Integer c = 4;

        BigDecimal applyMultiply = applePrice.multiply(new BigDecimal(a.toString()));
        BigDecimal strawberryMu = strawberryPrice.multiply(new BigDecimal(b.toString()));
        BigDecimal mongoMu = mangoPrice.multiply(new BigDecimal(c.toString()));
        //顾客
        User userA = new User();
        userA.setName("A");
        userA.setBugTime(new Date());
        userA.setSumPrice(strawberryMu.add(applyMultiply));

        User userB = new User();
        userB.setName("B");
        userB.setBugTime(new Date());
        userB.setSumPrice(strawberryMu.add(applyMultiply).add(mongoMu));

        User userC = new User();
        userC.setName("C");
        userC.setBugTime(new Date());
        BigDecimal strawberryMu1 = strawberryMu.multiply(new BigDecimal("0.8"));
        userC.setSumPrice(strawberryMu1.add(applyMultiply).add(mongoMu));

        User userD = new User();
        userD.setName("D");
        userD.setBugTime(new Date());
        BigDecimal sumPrice = strawberryMu.add(applyMultiply).add(mongoMu);
        if(sumPrice.compareTo(new BigDecimal("100"))!=-1){
            sumPrice=sumPrice.subtract(new BigDecimal(10));
        }
        userD.setSumPrice(sumPrice);



        System.out.println("顾客A购买的商品总价是:"+userA.getSumPrice()+"元;顾客B购买的商品总价是:"+userB.getSumPrice()+"元;"+"顾客C购买的商品总价是:"+userC.getSumPrice()+"元;"+"顾客D购买的商品总价是:"+userD.getSumPrice()+"元");


    }
}
